package com.atguigu.tingshu.user.api;

import cn.hutool.json.JSONObject;
import com.atguigu.tingshu.common.login.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.util.AuthContextHolder;
import com.atguigu.tingshu.user.service.UserListenProcessService;
import com.atguigu.tingshu.vo.user.UserListenProcessVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@Tag(name = "用户声音播放进度管理接口")
@RestController
@RequestMapping("api/user/userListenProcess")
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserListenProcessApiController {

	@Autowired
	private UserListenProcessService userListenProcessService;


	@GuiguLogin
	@Operation(summary = "查看声音的播放进度")
	@GetMapping("getTrackBreakSecond/{trackId}")
	public Result<BigDecimal> getTrackBreakSecond(@PathVariable Long trackId) {
		BigDecimal trackBreakSecond = userListenProcessService.getTrackBreakSecond(trackId);
		return Result.ok(trackBreakSecond);
	}

	//api/user/userListenProcess/updateListenProcess
	@GuiguLogin
	@Operation(summary = "更新声音的播放进度")
	@PostMapping("updateListenProcess")
	public Result updateListenProcess(@RequestBody UserListenProcessVo userListenProcessVo){
		userListenProcessService.updateListenProcess(userListenProcessVo);
		return Result.ok();
	}

	///api/user/userListenProcess/getLatelyTrack
	@GuiguLogin
	@Operation(summary = "获取用户最近播放进度")
	@GetMapping("getLatelyTrack")
	public Result getLatelyTrack(){
	JSONObject jsonObject = userListenProcessService.getLatelyTrack();
	return  Result.ok(jsonObject);
	}



}





